package com.cjm.one.common.utils;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.cjm.one.model.system.entity.SysUserInfo;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AuthSysUserContextHolder {
    private final static TransmittableThreadLocal<SysUserInfo> authContextSysUser = new TransmittableThreadLocal<>();
    public static SysUserInfo getAuthContextSysUser() {
        SysUserInfo sysUserInfo = authContextSysUser.get();
        if (sysUserInfo == null) {
            log.warn("用户上下文缺失！请求路径：{}", RequestPathContextHolder.getPath());
        }
        return sysUserInfo;
    }
    public static void setAuthContextSysUser(SysUserInfo user) {
        authContextSysUser.set(user);
    }

}
